local PartnerListRender = app.mvc.createListViewCell(...)
local PartnerHeadIconRender = import(".PartnerHeadIconRender")
local colorDisable = cc.c3b(109,109,109)
--data =
function PartnerListRender.create(node)
    local sprite = PartnerListRender.extend(node or cc.CSLoader:createNode(Res.PartnerListItem))
    if node == nil then
        ccui.Helper:doLayout(sprite)
    end
    sprite:init()
    return sprite
end


function PartnerListRender:init(data)
    self.super.init(self, data)
    self:setContentSize( self._ui.Panel:getContentSize() )
    self:refresh()

    self._headIcon = PartnerHeadIconRender.create(self._ui["Panel/Panel_head"])
    self._headIcon:setTouchEnabled(false)

    self._ui["Panel/bg_normal"]:setTouchEnabled(true)
    self._ui["Panel/bg_normal"]:addTouchEventListener(function(sender,eventType)
        if eventType == ccui.TouchEventType.ended and self._cellModel and self._cellModel:getIndex() ~= self._cellModel:getFoucsIndex() then
            self:dispatchCellEvent("click", self._cellModel)
        end
    end)
end

function PartnerListRender:refresh()
    if not self._data then
        return
    end
    local data = self._data
    local quality = data:getQuality()
    self:freshBrightStatus()

    self._headIcon:setData(data)
    self._ui["Panel/combat"]:setString(data:getCombatPower())
    self._ui["Panel/name"]:setString(data:getName())
    if data:isHave() then
        self._ui["Panel/icon_combat"]:setVisible(true)
        self._ui["Panel/combat"]:setVisible(true)
        self._ui["Panel/null"]:setVisible(false)
        self._ui["Panel/name"]:setColor(data:getQualityColor())
    else
        self._ui["Panel/icon_combat"]:setVisible(false)
        self._ui["Panel/combat"]:setVisible(false)
        self._ui["Panel/null"]:setVisible(true)
        self._ui["Panel/name"]:setColor(colorDisable)
    end

    local type2Icon = data:getType2IconPath()
    if type2Icon then
		self._ui["Panel/champion"]:setVisible(true)
		self._ui["Panel/champion"]:loadTexture(type2Icon)
	else
		self._ui["Panel/champion"]:setVisible(false)
    end
    self._ui["Panel/equipped"]:setVisible(data:isEquiped())
    self:refreshRedPoint(data:canActive() or data:canLvQuality())
end


function PartnerListRender:refreshRedPoint(b)
    self._ui["Panel/dot"]:setVisible(b)
end

function PartnerListRender:freshBrightStatus()
    if self._cellModel then
        self._ui["Panel/bg_Select"]:setVisible(self._cellModel:getIndex() == self._cellModel:getFoucsIndex())
    else
        self._ui["Panel/bg_Select"]:setVisible(false)
    end
end

function PartnerListRender:onFoucsIndexChange(foucsIndex)
    self:freshBrightStatus()
end


return PartnerListRender